home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gp_dvx.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.0 KB  |  115 lines

  1. /* Copyright (C) 1989, 1995, 1998 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gp_dvx.c,v 1.2 2000/09/19 19:00:24 lpd Exp $ */
  20. /* Desqview/X-specific routines for Ghostscript */
  21. #include "string_.h"
  22. #include "gx.h"
  23. #include "gsexit.h"
  24. #include "gp.h"
  25. #include "time_.h"
  26.  
  27. /* Do platform-dependent initialization. */
  28. void
  29. gp_init(void)
  30. {
  31. }
  32.  
  33. /* Do platform-dependent cleanup. */
  34. void
  35. gp_exit(int exit_status, int code)
  36. {
  37. }
  38.  
  39. /* Exit the program. */
  40. void
  41. gp_do_exit(int exit_status)
  42. {
  43.     exit(exit_status);
  44. }
  45.  
  46. /* ------ Miscellaneous ------ */
  47.  
  48. /* Get the string corresponding to an OS error number. */
  49. /* All reasonable compilers support it. */
  50. const char *
  51. gp_strerror(int errnum)
  52. {
  53.     return strerror(errnum);
  54. }
  55.  
  56. /* ------ Date and time ------ */
  57.  
  58. /* Read the current time (in seconds since Jan. 1, 1970) */
  59. /* and fraction (in nanoseconds). */
  60. void
  61. gp_get_realtime(long *pdt)
  62. {
  63.     struct timeval tp;
  64.     struct timezone tzp;
  65.  
  66.     if (gettimeofday(&tp, &tzp) == -1) {
  67.     lprintf("Ghostscript: gettimeofday failed!\n");
  68.     gs_exit(1);
  69.     }
  70.     /* tp.tv_sec is #secs since Jan 1, 1970 */
  71.     pdt[0] = tp.tv_sec;
  72.     pdt[1] = tp.tv_usec * 1000;
  73.  
  74. #ifdef DEBUG_CLOCK
  75.     printf("tp.tv_sec = %d  tp.tv_usec = %d  pdt[0] = %ld  pdt[1] = %ld\n",
  76.        tp.tv_sec, tp.tv_usec, pdt[0], pdt[1]);
  77. #endif
  78. }
  79.  
  80. /* Read the current user CPU time (in seconds) */
  81. /* and fraction (in nanoseconds).  */
  82. void
  83. gp_get_usertime(long *pdt)
  84. {
  85.     gp_get_realtime(pdt);    /* Use an approximation for now.  */
  86. }
  87.  
  88. /* ------ Printer accessing ------ */
  89.  
  90. /* Open a connection to a printer.  A null file name means use the */
  91. /* standard printer connected to the machine, if any. */
  92. /* Return NULL if the connection could not be opened. */
  93. extern void gp_set_file_binary(P2(int, int));
  94. FILE *
  95. gp_open_printer(char fname[gp_file_name_sizeof], int binary_mode)
  96. {
  97.     if (strlen(fname) == 0 || !strcmp(fname, "PRN")) {
  98.     if (binary_mode)
  99.         gp_set_file_binary(fileno(stdprn), 1);
  100.     stdprn->_flag = _IOWRT;    /* Make stdprn buffered to improve performance */
  101.     return stdprn;
  102.     } else
  103.     return fopen(fname, (binary_mode ? "wb" : "w"));
  104. }
  105.  
  106. /* Close the connection to the printer. */
  107. void
  108. gp_close_printer(FILE * pfile, const char *fname)
  109. {
  110.     if (pfile == stdprn)
  111.     fflush(pfile);
  112.     else
  113.     fclose(pfile);
  114. }
  115.